package com.wazzapps.sdk;

import android.app.Activity;

import com.facebook.internal.AnalyticsEvents;
import com.wazzapps.sdk.utils.Tools;

public class WazzApplication {
    public static final int SDK_VERSION = 20200408;
    private static WazzApplicationInstance instance;

    public static boolean init(Activity activity, String str, boolean z, boolean z2, String str2) {
        if (activity == null) {
            return false;
        }
        if (instance == null) {
            WazzApplicationInstance wazzApplicationInstance = new WazzApplicationInstance(activity);
            instance = wazzApplicationInstance;
            wazzApplicationInstance.init(str, Boolean.valueOf(z), z2, str2);
        }
        return instance.isInited();
    }

    public static boolean isInited() {
        WazzApplicationInstance wazzApplicationInstance = instance;
        return wazzApplicationInstance != null && wazzApplicationInstance.isInited();
    }

    public static boolean isWrongAppSignature() {
        WazzApplicationInstance wazzApplicationInstance = instance;
        return wazzApplicationInstance != null && WazzChecker.isWrongAppSignature(wazzApplicationInstance.getContext());
    }

    public static String getUser() {
        WazzApplicationInstance wazzApplicationInstance = instance;
        if (wazzApplicationInstance != null) {
            return wazzApplicationInstance.getUser();
        }
        return null;
    }

    public static String getCountry(Activity activity, String str) {
        return Tools.getCountryFromNetwork(activity, str);
    }

    public static String getReferrer() {
        WazzApplicationInstance wazzApplicationInstance = instance;
        return wazzApplicationInstance != null ? wazzApplicationInstance.getReferrer() : "";
    }

    public static boolean isDebugMode() {
        WazzApplicationInstance wazzApplicationInstance = instance;
        return wazzApplicationInstance != null && wazzApplicationInstance.isDebug();
    }

    public static String getUserCountry() {
        WazzApplicationInstance wazzApplicationInstance = instance;
        return wazzApplicationInstance != null ? Tools.getCountryFromNetwork(wazzApplicationInstance.getContext()) : AnalyticsEvents.PARAMETER_DIALOG_OUTCOME_VALUE_UNKNOWN;
    }

    public static void logEvent(String str) {
        WazzApplicationInstance wazzApplicationInstance = instance;
        if (wazzApplicationInstance != null) {
            wazzApplicationInstance.logEvent(str);
        }
    }

    public static void logEvent(String str, String str2) {
        WazzApplicationInstance wazzApplicationInstance = instance;
        if (wazzApplicationInstance != null) {
            wazzApplicationInstance.logEvent(str, str2);
        }
    }

    public static void logEvent(String str, String str2, String str3) {
        WazzApplicationInstance wazzApplicationInstance = instance;
        if (wazzApplicationInstance != null) {
            wazzApplicationInstance.logEvent(str, str2, str3);
        }
    }

    public static void logEvent(String str, String str2, String str3, String str4) {
        WazzApplicationInstance wazzApplicationInstance = instance;
        if (wazzApplicationInstance != null) {
            wazzApplicationInstance.logEvent(str, str2, str3, str4);
        }
    }

    public static void logEvent(String str, String str2, String str3, String str4, String str5) {
        WazzApplicationInstance wazzApplicationInstance = instance;
        if (wazzApplicationInstance != null) {
            wazzApplicationInstance.logEvent(str, str2, str3, str4, str5);
        }
    }

    public static int isAllowedPersonalization(Activity activity) {
        ConsentState state = ConsentState.getState(activity.getPreferences(0));
        if (state.personalisation == 2) {
            return 1;
        }
        if (state.personalisation == 3) {
            return 2;
        }
        return 0;
    }
}